package com.dly2024.soft.controller;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api
public class TestController {

    private String username = "";

    public TestController() {
        System.out.println("TestController初始化对象------------------------------------");
    }

    @GetMapping("/test")
    public String test(@RequestParam String username, HttpServletRequest request) {   // 可以返回普通数据类型、map、list、set、array
        this.username = username;   // 不适合开发规范的设定
        return "hello! " + username + "  id=" + request.getSession().getId();
    }

    @GetMapping("/hello")
    public String hello() {
        return "hello " + this.username;
    }
}
